<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
 	<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
</head>
<body>
<div class="container-fluid" id="main-container">
    <div id="page-content" class="clearfix">
        <div class="row-fluid">
            <div class="row-fluid">
                <!-- 检索  -->
                <div class="ibox-title" style="border-color: white;">
                    <div class="row">
                    	<div class="col-sm-12">
							<div class="form-group form-inline">
							    <span>确认参会人员参会情况：</span>
                                <select class="form-control"  id="attendee" name="attendee" >
									<option value="">==请选择==</option>
									<option value="0">未确认</option>
									<option value="1">是</option>
									<option value="2">否</option>
							    </select>
								<span>&nbsp;&nbsp;&nbsp;&nbsp;参会人员名称：</span>
								<input id="confereesNames" name="confereesNames" type="text" placeholder="请输入名称" class="input-sm form-control" style="width: 15%;">
								<input type="hidden" id="meetingId" value="${meetingId }" />
                                    <a id="find_btn" type="button" class="btn btn-sm btn-primary"> 搜索</a> 
                                    <a id="reset_btn" type="button" class="btn btn-sm btn-warning"> 重置</a>
							</div>
						</div>
                        <%-- <div class="col-sm-3" style="border: 2px solid blue;">
                            <div class="input-group form-inline">
	                            <s:hasPermission name="meetingSure:add">
	                            	<span class="input-group-btn" style="float: left; margin-left: 25px;">
	                             		<a  class="btn btn-sm btn-success" style="margin-left: 20px;" onclick="showadd();"> 添加</a>
	                             	</span>
	                            </s:hasPermission>
                             </div>
                        </div> --%>
                    </div>
                </div>
                <!-- biaogebigin -->
                <div class="ibox-content" style=" padding-left: 0px; margin-top: 10px;">
                    <div class="jqGrid_wrapper">
                        <table id="table_list"></table>
                        <div id="pager_list"></div>
                    </div>
                </div>
                <!-- tableover -->
            </div>
            <!-- PAGE CONTENT ENDS HERE -->

        </div>
        <!--/row-->
    </div>
    <!--/#page-content-->
</div>
<!--/.fluid-container#main-container-->
<script type="text/javascript">
    var meetingid = $("#meetingId").val();
    $(top.hangge());
        $.jgrid.defaults.styleUI = "Bootstrap";
        $("#table_list").jqGrid({
            url: '<%=contextPath%>/meetingSure/listData',
            datatype: "json",
            postData: {'pid':meetingid}, //发送数据
            autowidth: true,
            rownumbers: true,
            shrinkToFit: true,
            sortname: 'createDate',
            sortorder: "desc",
            mtype: "post",
            rowNum: 10,
            rowList: [10, 20, 30],
            colNames: [
			"id",
			"会议室ID",
			"会议室名称",
			"参会人员ID",
			"参会人员",
			"确认参会人员参会情况",
			"未能参与原因",
			"备注",
	        "操作"],
            colModel: [
			{name: "id",index: "id",hidden: true}, 
			{name:"meetingId",index:"meetingId",width:100,hidden: true},
			{name:"meetingName",index:"meetingName",width:100},
			{name:"conferee",index:"conferee",width:100,hidden: true},
			{name:"confereesName",index:"confereesName",width:100},
			{name:"attendee",index:"attendee",
				formatter: function (cellvalue, options, row) {
					if (cellvalue==0) {/* <i class='icon-edit'></i> */
						return "<span class='btn-sm btn-warning'>未确认</span>";
					} else if(cellvalue==1) {
						return "<span class='btn-sm btn-info'>是</span>";
					} else if(cellvalue==2) {
						return "<span class='btn-sm btn-danger'>否</span>";
					}
				},width:155
			},
			{name:"reason",index:"reason",
				formatter: function (cellvalue, options, row) {
					if (cellvalue==null || cellvalue=="" || cellvalue=="undefined") {
						return "暂无";
					} else {
						return cellvalue;
					}
				},width:220
			},
			{name:"remark",index:"remark",
				formatter: function (cellvalue, options, row) {
					if (cellvalue==null || cellvalue=="" || cellvalue=="undefined") {
						return "暂无";
					} else {
						return cellvalue;
					}
				},width:100,hidden: true
			},
	        {
                formatter: function (cellvalue, options, row) {
                	if (row.attendee == 0) {
                		return " <s:hasPermission name="meetingSure:edit"><a class='btn-sm btn-warning' title='修改' onclick='showedit(&quot;" + row.id + "&quot;)'>是否参会</a></s:hasPermission> " +
          	                   " <s:hasPermission name="meetingSure:delete"><a class='btn-sm btn-danger' title='删除' onclick='del(&quot;" + row.id + "&quot;)'><i class='icon-trash'></i></a></s:hasPermission> ";
					} else {
						return " <s:hasPermission name="meetingSure:delete"><a class='btn-sm btn-danger' title='删除' onclick='del(&quot;" + row.id + "&quot;)'><i class='icon-trash'></i></a></s:hasPermission> ";
					}
                },
                width: 130
            }],
            height: $(window).height() - 170,
            pager: "#pager_list",
            multiselect: true,//多选按钮
            //multiboxonly: true,
            viewrecords: true,
            hidegrid: false
        });
        //表格自适应高宽
        $(window).bind("resize", function () {
            var b = $(".jqGrid_wrapper").width();
            $("#table_list").setGridWidth(b);
            $("#table_list").setGridHeight($(window).height() - 170);
        })
        $("#table_list").navGrid('#pager_list', {edit: false, add: false, del: false, search: false})
        /* 判断是否有添加权限 */
        //检索
        $("#find_btn").click(function () {
            var confereesNames = $("#confereesNames").val();
            var attendee = $("#attendee").val();
            $("#table_list").jqGrid('setGridParam', {
                postData: {'confereesNames': confereesNames,'attendee': attendee}, //发送数据
                page: 1
            }).trigger("reloadGrid"); //重新载入
        });
        //重置
        $("#reset_btn").click(function(){ 
        	location.reload();
		});
    //查看
    function showeye(id) {
        openyem("查看会议确认", "<%=contextPath%>/meetingSure/detailView?id=" + id, 550, 500);
    }
    //删除
    function del(id) {
        swalopen(id, "<%=contextPath%>/meetingSure/delete");
    };
    //修改确认参会人员参会情况【0：未确认，1：是，2：否】
    function showedit(id) {
    	swal({ 
			title: "是否确认参会？", 
			type: "warning", 
			showCancelButton: true, 
			confirmButtonColor: "#DD6B55", 
			confirmButtonText: "No", 
			cancelButtonText: "Yes", 
			closeOnConfirm: false, 
			closeOnCancel: false 
		}, function(isConfirm) { 
			if (isConfirm) { 
				swal({
       		    	title:"请填写",
       		    	type: "input",
       		    	showCancelButton: true, 
       			    closeOnConfirm: false, 
       			    cancelButtonText: "取消", 
       			    confirmButtonText: "确认",
       		    	inputPlaceholder: "请填写未参加原因",
       		    	showLoaderOnConfirm: true
       		    },function(inputValue){ 
       				if(inputValue === false){
       					return false
       				}else {
       					if (inputValue === "") { 
       						swal.showInputError("请填写未参加原因");
       					    return false 
       					}else{
       						$.ajax({
       							url: '<%=contextPath%>/meetingSure/update',
       							data:{
       								'id':id,
       								'attendee':2,
       								'reason':inputValue
       								},
       			                type: 'post',
       			                dataType: "json",
       			                beforeSend: function () {
       						        // 禁用按钮防止重复提交
       								swal("信息已经提交，请等待后台处理~！");
       						    },
       							success : function(data) {
       								if (data.code == 200) {
       									swal({
       										title : data.message,
       										type : "success",
       										showCancelButton : false,
       										confirmButtonText : "确定",
       										animation : "slide-from-bottom",
       										text: "2秒后自动关闭。", 
       				      	    			timer: 2000, 
       										closeOnConfirm : true
       									}, function() {
       										window.location.reload();//刷新当前页面
       									});
       								} else {
       									swal("错误", data.message, "error");
       								}  
       							}
       						});
       					}
					}
       			});
			} else{ 
				$.ajax({
					url: '<%=contextPath%>/meetingSure/update',
					data:{
						'id':id,
						'attendee':1
						},
	                type: 'post',
	                dataType: "json",
	                beforeSend: function () {
				        // 禁用按钮防止重复提交
						swal("信息已经提交，请等待后台处理~！");
				    },
					success : function(data) {
						if (data.code == 200) {
							swal({
								title : data.message,
								type : "success",
								showCancelButton : false,
								confirmButtonText : "确定",
								animation : "slide-from-bottom",
								text: "2秒后自动关闭。", 
		      	    			timer: 2000, 
								closeOnConfirm : true
							}, function() {
								window.location.reload();//刷新当前页面
							});
						} else {
							swal("错误", data.message, "error");
						}  
					}
				});
			}
		})
    }
    //添加
    function showadd(id) {
        openyem("添加会议确认", "<%=contextPath%>/meetingSure/addView", 550, 500);
    }
</script>
</body>
</html>

